package LeetCode;

public class LC_053_MaximumSubarray {
    public static void main(String[] args) {

    }

    static class Solution {

        public static int maxSubArray(int[] nums) {
            int[] sum = new int[nums.length];
            int max = nums[0];
            sum[0] = nums[0];
            for (int i = 1; i < nums.length; i++) {
                sum[i] = Math.max(nums[i], sum[i - 1] + nums[i]);
                max = Math.max(max, sum[i]);
            }
            return max;
        }

    }

}
